package com.itHuangTao.tank.ui;

import com.almasb.fxgl.app.scene.FXGLMenu;
import com.almasb.fxgl.app.scene.MenuType;
import com.almasb.fxgl.audio.AudioPlayer;
import com.almasb.fxgl.audio.Music;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.texture.Texture;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;

import static com.almasb.fxgl.dsl.FXGL.loopBGM;

public class TankMainMenu extends FXGLMenu {
    public TankMainMenu() {
        super(MenuType.MAIN_MENU);
        Texture texture = FXGL.texture("menuSceneBg.png");
        //设置两个按钮
        Button btnStart = new Button("开始游戏");
        btnStart.setOnAction(event -> {
            FXGL.getGameController().startNewGame();
            FXGL.play("menuTogameBgm.wav");
        });
        btnStart.getStyleClass().add("menu-btn");//利用css设置样式

        Button btnExit = new Button("退出游戏");
        btnExit.getStyleClass().add("menu-btn");//利用css设置样式
        btnExit.setOnAction(event -> FXGL.getGameController().exit());

        Button btnHelp = new Button("关于我们");
        btnHelp.getStyleClass().add("menu-btn");//利用css设置样式
        btnHelp.setOnAction(event -> FXGL.getSceneService().pushSubScene(new HelpMenu()));

        //设置垂直间隔为30个像素点(并存放上述按钮对象)
        VBox box = new VBox(30, btnStart, btnExit, btnHelp);
        box.setLayoutX(370);
        box.setLayoutY(350);

        //加入所有变量
        getContentRoot().getChildren().addAll(texture, box);
    }

}
